package cn.rongdao.jrkabao.ui.message;

import android.content.Intent;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mifengkong.frwidget.titlebar.TitleBarUIComponent;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.base.BaseAutoFinishActivity;
import cn.rongdao.jrkabao.constant.InfoConstant;


/**
 * Created by jiangyongxing on 2016/11/30.
 * 描述：
 */

public class LoanMessageDetailActivity extends BaseAutoFinishActivity implements View.OnClickListener {

    private String time = "";
    private TextView mTimeTextView;
    private RelativeLayout mModifyRl;
    private TitleBarUIComponent titleBarUIComponent;
    private TextView mDetailMessage;
    private String mMessage;


    @Override
    protected int layoutRes() {
        return R.layout.activity_detailinfo;
    }

    @Override
    protected void initView() {
        initData();
        titleBarUIComponent = (TitleBarUIComponent) findViewById(R.id.ad_titlebar);
        initTitleBar();
        mTimeTextView = (TextView) findViewById(R.id.activity_detailinfo_time);
        mDetailMessage = (TextView) findViewById(R.id.activity_detailinfo_message);
        mTimeTextView.setText(time);
        mModifyRl = (RelativeLayout) findViewById(R.id.activity_detailinfo_modify_rl);
        mModifyRl.setOnClickListener(this);
        if (!TextUtils.isEmpty(mMessage))
            mDetailMessage.setText(mMessage);
    }


    protected void initData() {
        time = getIntent().getStringExtra("time");
        mMessage = getIntent().getStringExtra("message");
    }

    private void initTitleBar() {
        titleBarUIComponent.initTitleBlack("详情");
        titleBarUIComponent.setBottomViewVisiable(true);
        titleBarUIComponent.setBackgroundColor(ContextCompat.getColor(this, R.color.white));
        titleBarUIComponent.initLeftBackBlack(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.activity_detailinfo_modify_rl:
                Intent intent = new Intent(this, MessageRebackActivity.class);
                intent.putExtra("type", "modify");
                startActivityForResult(intent, 1);
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1 && resultCode == RESULT_OK) {
            if (data != null && "modify_success".equals(data.getStringExtra("data"))) {
                setResult(InfoConstant.RESULT_CODE_MESSAGEDETAILACTIVITY);
                finish();
            }
        }
    }


}
